<?php

function dohtml_header()//------------------------------------------------------
{
global $h1;
global $h2;
global $h3;
global $id_page;
$titre=$h1.' - '.$h2;
if ($id_page)
    $titre.=' ('.$id_page.')';
if ($h3)
    $titre.=' - '.$h3;
global $tinymce;
global $scripts;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">

<head>
    <title><?=$titre ?></title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="generator" content="Geany" />
    <meta name="author" content="Bruno Paulin" />
    <link rel='stylesheet' type='text/css' href='style/bpc.css'/>
    <link rel='stylesheet' type='text/css' href='style/datepicker.css'/>
    <script type="text/javascript" src="inc/plugins/tigracal/calendar_eu.js"></script>
	<script type="text/javascript" src="javascript/datepicker.js"></script>
<?php
//Scripts
if (!empty($scripts))
	foreach	($scripts as $s)
		echo "<script type='text/javascript' src='javascript/$s'></script>";
if ($tinymce){
?>
<script type="text/javascript" src="inc/plugins/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
    language : "fr",
    plugins : "autosave"
});
</script>
<?php
}
?>
</head>
<body>
<div id='conteneur'>

<?php
}//----------------------------------------------------------------dohtml_header


function dohtml_h1()//------------------------------------------------
{
global $h1;
?>
<h1><a name='haut_page'></a><?=$h1?></h1>
<?php
}//----------------------------------------------------------------dohtml_header


function dohtml_h2()//------------------------------------------------
{
global $h2;
global $id_page;
global $lienpdf;
$texte=$h2;
if ($id_page)
    $texte.=' <span>('.$id_page.')</span>';
if ($lienpdf)
    $texte.=' '.$lienpdf;
?>
<h2><?=$texte?></h2>
<?php
}//----------------------------------------------------------------dohtml_header


function dohtml_h3()//------------------------------------------------
{
global $h3;
?>
<h3><?=$h3?></h3>
<?php
}//----------------------------------------------------------------dohtml_header

function dohtml_h4($h4)//------------------------------------------------
{
?>
<h4><?=$h4?></h4>
<?php
}//----------------------------------------------------------------dohtml_header

function dohtml_menurapide()//------------------------------------------------
{
?>
<div id='menurapide'>
    <ul>
        <li>
            <strong><?= $_SESSION[SES_USER_NOM] ?></strong>
        </li>
        <li>
            <a href='logout.php'>Déconnexion</a>
        </li>
        <li>
            <form method='post' action='resultats.php' class='integre'>
                <label for='critere'>Rechercher</label>
                <input id='critere' name='critere' type='text'/>
                <input type="submit" name='rech_rapide' value='Ok' />
            </form>
        </li>
    </ul>
</div>
<?php
}//----------------------------------------------------------------dohtml_header


function dohtml_fildariane()//------------------------------------------------
{
?>
<ul id='fildariane'>
    <li>&#187; <a href='modele.php'>A10</a></li>
    <li>&#187; <a href='client.php'>Microsoft</a></li>
    <li>&#187; <a href='rapport.php'>Nouveau rapport</a></li>
</ul>
<?php
}//----------------------------------------------------------------dohtml_header


function dohtml_menu()
{
?>
<div id='menu'>
    <p>
        Recherche
    </p>
    <ul class='sousmenu'>
        <li>
            <?php dohtml_lien('rechclients.php','Client')?>
        </li>
        <li>
            <?php dohtml_lien('rechmachines.php','Machine')?>
        </li>    
    </ul>
    <p>
        Ajout
    </p>
    <ul class='sousmenu'>
        <li>
            <?php dohtml_lien('ajoutclient.php','Client')?>
        </li>
        <!--<li>
            <?php dohtml_lien('contact.php?id=-1','Contact')?>
        </li>    
        <li>
            <?php dohtml_lien('modele.php?id=-1','Modèle')?>
        </li> --> 
    </ul>
    <p>
        Gestion
    </p>
    <ul class='sousmenu'>
        <li>
            <?php dohtml_lien('utilisateurs.php', LNG_UTI_COURT, LNG_UTI_LONG)?>
        </li>
        <li>
            <?php dohtml_lien('modeles.php', LNG_MOD_COURT, LNG_MOD_LONG)?>
        </li>
        <li>
            <?php dohtml_lien('branches.php', LNG_BRA_COURT, LNG_BRA_LONG)?>
        </li>
        <li>
            <?php dohtml_lien('zones.php', LNG_ZON_COURT, LNG_ZON_LONG)?>
        </li>
    </ul>
    <p>
		Actions
	</p>
	<ul class='sousmenu'>
        <li>
            <?php dohtml_lien('news.php','Actualités')?>
        </li>
        <li>
            <?php dohtml_lien('actions.php','Utilisation')?>
        </li>
        <li>
            <?php dohtml_lien('mailings.php','Mailings')?>
        </li>
	</ul>
<!--    <p>
        Actions
    </p>
    <ul class='sousmenu'>
        <li>
            <?php dohtml_lien('mailings.php','Mailings')?>
        </li>
        <li>
            <?php dohtml_lien('rapports.php','Rapports')?>
        </li>    
    </ul>
    <p>
        Aide
    </p>    
    <ul class='sousmenu'>
        <li>
            <?php dohtml_lien('doc.php','Documentation')?>
        </li>
        <li>
            <?php dohtml_lien('aide.php','Aide')?>
        </li>    
        <li>
            <?php dohtml_lien('apropos.php','A propos')?>
        </li>    
    </ul>-->
</div>
<?php
}

function dohtml_recap($nb_requetes)
{
global $temps_debut;
$temps=1000*(microtime(true)-$temps_debut);
?>
<div id='pied'>
    <?php printf(LNG_RECAP, $nb_requetes, $temps); ?>
</div>    
<?php
}

function dohtml_statut()
{
	echo ( empty($_SESSION[SES_STATUT]) ) ? '': $_SESSION[SES_STATUT];
}

function dohtml_init($log=TRUE)
{
    // On affiche l'en tete html
    dohtml_header();
	if ( DEBUG )
	{
		echo 'GET : ';
		print_r($_GET);
		echo "<br/>\n";
		echo 'POST : ';
		print_r($_POST);
		echo "<br/>\n";
		echo 'COOKIE : ';
		print_r($_COOKIE);
		echo "<br/>\n";
	}
	dohtml_statut();
    // On affiche le titre du site
    dohtml_h1();
    if ($log)
    {
        // On affiche le menu rapide
        dohtml_menurapide();
        // On affiche le fil d'ariane
        //dohtml_fildariane();
        // On affiche le menu
        dohtml_menu();
    }
    // On ouvre le conteneur principal
    echo "<div id='principal'>";
    // On affiche le titre de la page
    dohtml_h2();    
}

function dohtml_final($log=TRUE)
{
    global $db;
    echo '</div><!-- principal -->';
    if ($log)
        dohtml_recap($db->nb_requetes);
 	if ( DEBUG )
		$db->debug();
	echo '</div><!-- conteneur -->';
	echo '</body>';
    echo '</html>';
	$_SESSION[SES_STATUT] = '';
}
?>
